#include "MyWidget.h"

#include <qtimer.h>
#include <qlayout.h>

#include "InnerWidget.h"
#include "DownWidget.h"


MyWidget::MyWidget(QWidget * parent, const char * name)
	: QWidget(parent, name, (Qt::WStyle_Customize | WStyle_NoBorder | WStyle_Tool))
{
	setPaletteBackgroundColor(QColor(128, 128, 128));
	QVBoxLayout * pVBoxLayout = new QVBoxLayout(this);
	pVBoxLayout->setMargin(1);

	pInnerWidget = new InnerWidget(this);
	pVBoxLayout->addWidget(pInnerWidget);		

	pDownWidget = new DownWidget(this);
	pVBoxLayout->addWidget(pDownWidget);
	
	timerHide = new QTimer(this);
	connect(timerHide, SIGNAL(timeout()), SLOT(hide_time()));
}

MyWidget::~MyWidget()	
{
//	qDebug("~MyWidget");
}

void MyWidget::enterEvent(QEvent *)
{
    timerHide->stop();
}

void MyWidget::leaveEvent(QEvent *)
{
    hide();
}

void MyWidget::show()
{
	timerHide->stop();
	QWidget::show();
}

void MyWidget::hide()
{
    timerHide->start(100, TRUE);
}

void MyWidget::hide_time()
{
    QWidget::hide();	    
}
